/*
 * @Date: 2024-11-07 17:05:23
 * @Author: LiSong
 * @LastEditors: LiSong
 * @LastEditTime: 2024-11-12 09:31:29
 * @Description: 请求类型定义
 */
import { PojoUtils } from '../cfg/PojoUtils'

/**
 * 请求类型定义
 */
export class RequestType {
  constructor (label, value) {
    this.label=label
    this.value=value
  }

  static get GET() {
    return new RequestType('get请求', 'GET')
  }
  static get POST() {
    return new RequestType('post请求', 'POST')
  }
}

/**
 * 请求类型数据集
 */
export class RequestTypes {
  /**
   * 获取请求类型的数组
   * 
   * @returns {Array}
   */
  static getData () {
    const staticKeys = PojoUtils.getOwnPropertyStatics(RequestType)
    const staticItems = staticKeys.map(key => RequestType[key])
    return staticItems
  }
}


/**
 * 请求参数类型
 */
export class RequestParamType {
  constructor (label, value) {
    this.label=label
    this.value=value
  }
  static get DATA() {
    return new RequestParamType('data', 'data')
  }
  static get PARAMS() {
    return new RequestParamType('params', 'params')
  }
}

export class RequestParamTypes {
  /**
   * 获取请求类型的数组
   * 
   * @returns {Array}
   */
  static getData () {
    const staticKeys = PojoUtils.getOwnPropertyStatics(RequestParamType)
    const staticItems = staticKeys.map(key => RequestParamType[key])
    return staticItems
  }
}
